<?php

class Jf_Bootstrap extends Jf_Bootstrap_Abstract {

    /**
     * 引导文件Bootstrap.php解析处理
     * 
     * @param Jf_Bootstrap_Abstract $bootstrap
     * @param Jf_Controller_Dispatcher $dispatcher
     */
    public static function bootstrap(Jf_Bootstrap_Abstract $bootstrap, Jf_Controller_Dispatcher $dispatcher) {
        if (version_compare(PHP_VERSION, '5.2.6') === - 1) {
            $class = new ReflectionObject($bootstrap);
            $classMethods = $class->getMethods();
            $methodNames = array();
            foreach ($classMethods as $method) {
                $methodNames[] = $method->getName();
            }
        } else {
            $methodNames = get_class_methods($bootstrap);
        }
        $initMethodLength = strlen(self::BOOTSTRAP_INITFUNC_PREFIX);
        foreach ($methodNames as $method) {
            if ($initMethodLength < strlen($method) && self::BOOTSTRAP_INITFUNC_PREFIX === substr($method, 0, $initMethodLength)) {
                $bootstrap->$method($dispatcher);
            }
        }
    }
}
